package com.cazor.dg.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cazor.common.annotation.Log;
import com.cazor.common.core.controller.BaseController;
import com.cazor.common.core.domain.AjaxResult;
import com.cazor.common.enums.BusinessType;
import com.cazor.dg.domain.DgDevDeviceInstance;
import com.cazor.dg.service.IDgDevDeviceInstanceService;
import com.cazor.common.utils.poi.ExcelUtil;
import com.cazor.common.core.page.TableDataInfo;

/**
 * 检监测内容Controller
 * 
 * @author cazor
 * @date 2023-11-25
 */
@RestController
@RequestMapping("/dg/dgDeviceInstance")
public class DgDevDeviceInstanceController extends BaseController
{
    @Resource
    private IDgDevDeviceInstanceService dgDevDeviceInstanceService;

    /**
     * 查询检监测内容列表
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:list')")
    @GetMapping("/list")
    public TableDataInfo list(DgDevDeviceInstance dgDevDeviceInstance)
    {
        startPage();
        List<DgDevDeviceInstance> list = dgDevDeviceInstanceService.selectDgDevDeviceInstanceList(dgDevDeviceInstance);
        return getDataTable(list);
    }

    /**
     * 导出检监测内容列表
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:export')")
    @Log(title = "检监测内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DgDevDeviceInstance dgDevDeviceInstance)
    {
        List<DgDevDeviceInstance> list = dgDevDeviceInstanceService.selectDgDevDeviceInstanceList(dgDevDeviceInstance);
        ExcelUtil<DgDevDeviceInstance> util = new ExcelUtil<DgDevDeviceInstance>(DgDevDeviceInstance.class);
        util.exportExcel(response, list, "检监测内容数据");
    }

    /**
     * 获取检监测内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dgDevDeviceInstanceService.selectDgDevDeviceInstanceById(id));
    }

    /**
     * 新增检监测内容
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:add')")
    @Log(title = "检监测内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DgDevDeviceInstance dgDevDeviceInstance)
    {
        return toAjax(dgDevDeviceInstanceService.insertDgDevDeviceInstance(dgDevDeviceInstance));
    }

    /**
     * 修改检监测内容
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:edit')")
    @Log(title = "检监测内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DgDevDeviceInstance dgDevDeviceInstance)
    {
        return toAjax(dgDevDeviceInstanceService.updateDgDevDeviceInstance(dgDevDeviceInstance));
    }

    /**
     * 删除检监测内容
     */
    @PreAuthorize("@ss.hasPermi('dg:dgDeviceInstance:remove')")
    @Log(title = "检监测内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dgDevDeviceInstanceService.deleteDgDevDeviceInstanceByIds(ids));
    }
}
